<?php session_start(); ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head><title>Parent Informer RCSHS - Pending Accounts Decisions</title></head>

<link rel=stylesheet href="../../../css-layouts/themes/defaulttheme.css" type="text/css">
<link rel=stylesheet href="../../../css-layouts/headlinks.css" type="text/css">
<link rel=stylesheet href="../../../css-layouts/imglinks.css" type="text/css">

</head>

<body>

<div id="mainhead"><br><br><br></div>

<?php 

 require_once("../../../sqlconfig.php");

 mysql_connect($server, $sqlusr, $sqlpass) or die(mysql_error());
 mysql_select_db($mydb) or die(mysql_error()); 

 //Checks if there is a login cookie
 if(isset($_COOKIE["parentinformerprcshs"]) || isset($_COOKIE["parentinformerurcshs"])) { 
  if(isset($_COOKIE["parentinformerprcshs"])) {
   $username = $_COOKIE["parentinformerprcshs"]; 
  }
  else {
   $_SESSION['theerrcode'] = 2;
   header("Location: ../../logerr_atmpt.php");
  }
  $pass = $_COOKIE["parentinformerurcshs"];
  $check = mysql_query("SELECT * FROM logtbl WHERE usernm = '".$username."'") or die(mysql_error());
  while($info=mysql_fetch_array($check)) {
   if ($pass!=$info['pwrnd']) {
    $_SESSION['theerrcode'] = 2;
    header("Location: ../../logerr_atmpt.php");
   }
   else {

    if($info['priv']!=1) {
     header("Location: ../../../");
     die();
    }

?>


<p class="leftnav">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Logged in as: <?php echo $_COOKIE["parentinformerprcshs"]; ?>
</p>

<p class="rightnav">

<b>Pending Accounts</b> || 
<a href="../../settings">Settings</a> || <a href="../../redirout.php">Logout</a>
</p>

<hr style="clear: both;"><br>

<center><font id="heading">REQUESTED ACCOUNTS</font></center>

<br><br>

<?php

    if($_POST['sltdacct']==0) {
     echo "You have not selected any users to revoke or approve.";
     die();
    }

    if(isset($_POST['revoke'])) {
     foreach($_POST['sltdacct'] as $theusrnm) {
      $revokeacct = mysql_query("DELETE FROM pendaccts WHERE desusr = '".$theusrnm."'") or die(mysql_error());
     }
     if($revokeacct) {
      echo "The selected users have been revoked. An e-mail was sent to them regarding<br>";
      echo "their account status.<br><br>";
      echo "Click <a href='decisions.php'>here</a> to return to the decisions page.<br>";
     }
    }

    if(isset($_POST['approve'])) {
     foreach($_POST['sltdacct'] as $addusrnm) {
      $doaddme = mysql_query("SELECT * FROM pendaccts WHERE desusr='".$addusrnm."'") or die(mysql_error());
      $addaccts = mysql_fetch_array($doaddme) or die(mysql_error());
      $acceptacct = mysql_query("INSERT INTO logtbl VALUES('$addaccts[0]', '$addaccts[1]', '$addaccts[3]', '$addaccts[2]', '', '', 'default', '', '')") or die(mysql_error());
      $delpendacct = mysql_query("DELETE FROM pendaccts WHERE desusr = '".$addusrnm."'") or die(mysql_error());
     }
     if($acceptacct && $delpendacct) {
      echo "The selected users have been accepted. An e-mail was sent to them regarding<br>";
      echo "their account status.<br><br>";
      echo "Click <a href='decisions.php'>here</a> to return to the decisions page.<br>";
     }
    }

?>

<br>

<div class="footnav" align=center>

<hr>


<a href="../../../">Main Page</a> ||
<a href="#">Help</a> ||
<a href="../../../externalaffairs/links.php">Links</a> ||
<a href="#">About</a>
<br>

<span id="copyme">
&copy; 2011 Roosevelt College Science High School. All rights reserved.
</span>

</div>

</body>

<?php
   }
  }
 }
 else {
  header("Location: ../../");
 }

?>

</html>